package com.java.zhuiyun.api.memberShip_records.controller;

import com.java.zhuiyun.api.memberShip_records.entity.UserMemberShip;
import com.java.zhuiyun.api.memberShip_records.service.MemberShipService;
import com.java.zhuiyun.common.response.CommonResult;
import com.java.zhuiyun.util.pageUtil.PageRequest;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName MemberShipController
 * @Description TODO 个人会员记录查询
 * @Author WX
 * @Date 2023/8/18 8:26
 **/
@RestController
@RequestMapping("/memberShip")
@CrossOrigin
@Api(tags = "订单记录管理")
public class MemberShipController {

    @Autowired
    private MemberShipService memberShipService;

    /*
    * @Author WX
    * @Description 生成订单
    * @Date 2023/8/18 9:01
    * @Return
    * @param UserMemberShip
    */
    @RequestMapping("/generateOrder")
    public CommonResult generateOrder (UserMemberShip userMemberShip){
        return CommonResult.ok(memberShipService.generateOrder(userMemberShip));
    }

    /*
    * @Author WX
    * @Description 查询个人会员购买记录
    * @Date 2023/8/18 13:57
    * @Return
    * @param id
    */
    @RequestMapping("/personInfoQuery")
    public CommonResult personInfoQuery(Integer id){
        return CommonResult.ok(memberShipService.personInfoQuery(id));
    }

    /*
    * @Author WX
    * @Description 查询所有会员记录
    * @Date 2023/8/28 11:23
    * @Return
    * @param null
    */
    @RequestMapping("/selectMemberShip")
    public CommonResult selectMemberShip (PageRequest pageRequest) {
        return  memberShipService.selectMemberShip(pageRequest);
    }

    /*
    * @Author WX
    * @Description 查询各种会员本月购买记录
    * @Date 2023/8/28 14:20
    * @Return
    * @param null
    */
    @RequestMapping("/members")
    public CommonResult getMembers(){
        return CommonResult.ok(memberShipService.getMembers());
    }

    /*
    * @Author WX
    * @Description 当年会员每月销量
    * @Date 2023/9/7 10:17
    * @Return
    * @param null
    */
    @RequestMapping("/getMemberMonth")
    public CommonResult getMemberMonth(String selectedYear){
        return CommonResult.ok(memberShipService.getMemberMonth(selectedYear));
    }

    /*
    * @Author WX
    * @Description 获取每年的课程和会员金额
    * @Date 2023/9/7 16:25
    * @Return
    * @param null
    */
    @RequestMapping("/getOrdersMembersmonth")
    public CommonResult getOrdersMembersmonth(String selectedYear) {
        return CommonResult.ok(memberShipService.getOrdersMembersmonth(selectedYear));
    }
}
